package com.greet.controller.user;

import com.greet.constant.RedisDataKeys;
import com.greet.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController("userShopController")
@RequestMapping("/user/shop")
@Slf4j
public class ShopController {
    @Autowired
    private RedisTemplate redisTemplate;

    @GetMapping("/status")
    public Result getStatus(){
        Integer shopStatus = (Integer) redisTemplate.opsForValue().get(RedisDataKeys.SHOP_STATUS);
        log.info("用户请求获取当前营业状态：<{}>", shopStatus == 1 ? "营业中" : "打烊中");
        return Result.success(shopStatus);
    }
}
